<template>
  <div class="new-table-style">
    <el-table :border="false" stripe :data="list">
      <el-table-column align="center" label="序号" width="60">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="工作描述" prop="description"></el-table-column>
      <el-table-column align="center" label="工作类型" prop="workTypeName" width="100"></el-table-column>
      <el-table-column align="center" label="重要程度" prop="importantDegree" width="110">
        <template slot-scope="scope">
          <span v-if="scope.row.importantDegree == 1">一般</span>
          <span class="color-red" v-if="scope.row.importantDegree == 2">重要</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="工作进展" prop="workStatus">
        <template slot-scope="scope">
          <span>{{scope.row.workStatusName}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="负责人" prop="processorName" width="90"></el-table-column>
      <el-table-column align="center" label="更新" prop="newestDescription"></el-table-column>
      <el-table-column align="center" label="开始日期" width="110" prop="startTime">
        <template slot-scope="scope">
          <span>{{ scope.row.startTime | formatDateTime('YYYY-MM-DD') }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="截止日期" prop="endTime">
        <template slot-scope="scope">
          <span>{{ scope.row.endTime | formatDateTime('YYYY-MM-DD') }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="相关部门">
        <template slot-scope="scope">
          <span>{{ scope.row.organizationNames[0] }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="type == 'last'" align="center" label="工作状态" prop="workStatusName"></el-table-column>
      <el-table-column align="center" label="状态">
        <template slot-scope="scope">
          <span v-if="scope.row.status == 1">已发布</span>
          <span v-if="scope.row.status == 2">未发布</span>
        </template>
      </el-table-column>

      <el-table-column align="center" label="操作" v-if="isHandle && meetingStatus == 1" width="180">
        <template slot-scope="scope">
          <el-button type="text" @click="workMeetingDo(scope.row, 'finish')">完成</el-button>
          <el-button type="text" @click="workMeetingDo(scope.row, 'continue')">延续</el-button>
          <el-button type="text" @click="workMeetingDo(scope.row, 'cancle')">取消</el-button>
          <el-button type="text" @click="workMeetingDo(scope.row, 'stop')">暂停</el-button>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" v-if="!isHandle && meetingStatus == 1">
        <template slot-scope="scope">
          <el-button type="text" @click="seaFn(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { apiMeetingDo } from '../../../api/workTrace';
import { requestTips, askDialog } from '../../../assets/util';

export default {
  props: {
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
    isHandle: {
      type: Boolean,
      default: false,
    },
    meetingStatus: {
      type: Number,
      default: 1,
    },
    type: {
      type: String,
      default: '',
    },
  },

  data() {
    return {};
  },

  methods: {
    //完成/延续/取消/暂停 "finish", "完成", "continue", "延续""cancle", "取消", "stop", "暂停",
    async workMeetingDo(item, handleType) {
      askDialog('确认操作？', async () => {
        let res = await apiMeetingDo({
          primaryKey: item.primaryKey,
          meetingSummaryKey: this.$route.query.meetingKey,
          operateType: handleType,
        });
        requestTips(res, async () => {
          this.$emit('refresh');
        });
      });
    },

    //查看
    seaFn(item) {
      this.$emit('seaFn', item);
    },
  },
};
</script>
<style lang="scss" scoped></style>
